from haystack import indexes
from goods.models import SKU


class SKUIndex(indexes.SearchIndex,indexes.Indexable):
    '''
    SKU索引类
    '''
    # 指定有哪些字段构成
    text = indexes.CharField(document=True,use_template=True)

    # 名字和ｉｄ中间空一格
    # text = object.name+object.id

    def get_model(self):

        return SKU

    def index_queryset(self, using=None):

        return self.get_model().objects.filter(is_launched=True)






